<template>
  <div class="form-horizontal">
    <UserBaseInfo :editable='editable' ref="baseinfo" v-bind:profile="editUserInfo.profile"></UserBaseInfo>
    <UserSource :editable='editable' ref="source" v-bind:employsource="editUserInfo.employsource"></UserSource>
    <Education :editable='editable' ref="education" v-bind:education="editUserInfo.education"></Education>
    <Job :editable='editable' ref="job" v-bind:job="editUserInfo.job"></Job>
    <Resumes :editable='editable' ref="resume" v-bind:resumes="editUserInfo.resumes"></Resumes>
  </div>
</template>
<script>
import bootstrapmodal from 'vue2-bootstrap-modal'
import Resumes from './Resumes'
import UserBaseInfo from './UserBaseInfo'
import Education from './Education'
import UserSource from './UserSource'
import Job from './Job'
import Channel from '../../mycomponents/common/Channel'
import Depart from '../../mycomponents/common/Depart'
export default {
  name: 'UserInfo',
  props:['userInfo','editable'],
  data: function () {
     return {
       editUserInfo:{
         profile:null,
         employsource:null,
         education:null,
         job:null,
         resumes:null
       }
     }
  },
  components: {
    UserBaseInfo,
    Channel,
    Depart,
    UserSource,
    Education,
    Job,
    Resumes
  },
  methods: {
    getData: function (ele) {

      var profData = this.$refs.baseinfo.getData()
      var eduData = this.$refs.education.getData()
      var empSource = this.$refs.source.getData()
      var jobData = this.$refs.job.getData()
      var resData = this.$refs.resume.getData()

      if(!profData || !eduData || !empSource || !jobData || !resData){
        return null
      }

      this.editUserInfo =  {
        profile: this.$refs.baseinfo.getData(),
        education: this.$refs.education.getData(),
        employsource: this.$refs.source.getData(),
        job: this.$refs.job.getData(),
        resumes: this.$refs.resume.getData()
      }
      console.log("userinfor:",JSON.stringify(this.editUserInfo))
      return this.editUserInfo
    }
  },
  created:function(){
    if( this.userInfo){
      this.editUserInfo = this.userInfo
    }
  }
}
</script>
<style scoped>

</style>
